package com.hbwxz.admin.controller;

import com.hbwxz.admin.pojo.CommodityBrand;
import com.hbwxz.admin.pojo.CommodityCategory;
import com.hbwxz.admin.service.CommodityBrandService;
import com.hbwxz.admin.service.CommodityCategoryService;
import com.hbwxz.common.response.CommonResponse;
import com.hbwxz.common.response.ResponseCode;
import com.hbwxz.common.response.ResponseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/commodity/brand")
public class CommodityBrandController {

    @Autowired
    private CommodityBrandService commodityBrandService;

    //新增brand
    @RequestMapping("/create")
    public CommonResponse createBrand(@RequestBody CommodityBrand commodityBrand){
        commodityBrandService.createBrand(commodityBrand);
        return ResponseUtils.okResponse(null);
    }
    //通过category id查询brand
    @RequestMapping("/listByCategoryId")
    public CommonResponse listByCategoryId(@RequestParam Long id){
        List<CommodityBrand> list = commodityBrandService.listByCategoryId(id);
        return ResponseUtils.okResponse(list);
    }
    //通过letter查询brand
    @RequestMapping("/listByLetter")
    public CommonResponse listByLetter(@RequestParam String letter){
        List<CommodityBrand> list = commodityBrandService.listByLetter(letter);
        return ResponseUtils.okResponse(list);
    }
    //删除brand
    @RequestMapping("/delete")
    public CommonResponse listByLetter(){
//        List<CommodityBrand> list = commodityBrandService.listByLetter(letter);
        //品牌删除 更新mysql相关内容 解绑category
        //mysql 商品信息 删除，ES删除
        //mysql 商品信息是否上架改成0 ES中进行删除 ES维护一个key
        return ResponseUtils.okResponse(null);
    }

}
